﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NHibernateDB;

namespace MedicalDB
{
    public partial class FormLimba : Form
    {
        public FormLimba()
        {
            InitializeComponent();
            string xmlFile = @"C:\Configurare.xml";
            XMLParser xmlParser = new XMLParser(xmlFile);

            List<string> namesForm2 = xmlParser.ExtractAttribute("Limbi", string.Empty, string.Empty, "name");

            foreach (string s in namesForm2)
                cbLimba.Items.Add(s);

            cbLimba.SelectedItem = namesForm2[0] ;
            Rename();
        }

        private void btSelecteazaLimba_Click(object sender, EventArgs e)
        {
            string xmlFile = @"C:\Configurare.xml";
            XMLParser xmlParser = new XMLParser(xmlFile);
            Dictionary<string, string> namesForm = xmlParser.ExtractAttributePairs("Configurare", string.Empty, string.Empty, "name", "formula");

            
            xmlParser.write("Configurare", "Limba", cbLimba.SelectedItem.ToString());

            FormDBMedical transfer = new FormDBMedical(cbLimba.Text, namesForm["ServerIP"],
                    namesForm["ServerPort"], namesForm["FTPIp"], namesForm["FTPUser"],
                    namesForm["FTPParola"], namesForm["FTPPort"]);


            transfer.Owner = this;

            Hide();
            transfer.ShowDialog();
            transfer.Focus();

            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PersistenceManager pm = new PersistenceManager();
            DateGeneralePacient dgp = new DateGeneralePacient();

            dgp.IdPacient = "28";
            dgp.Nume = "test";
            dgp.Prenume = "test";
            dgp.Sex = "f";
            dgp.DataNasterii = new DateTime(1987, 11, 2);
            dgp.LoculNasterii = "tm";
            dgp.Resedinta = "tm2";
            dgp.DomiciliuLegal = "tm3";
            dgp.GrupaSanguina = "ab";
            dgp.Ocupatie = "prog";
            dgp.LocMunca = "al";
            dgp.TalonPensie = "b";

            pm.Save(dgp);


        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            DateGeneralePacient dgp = new DateGeneralePacient();
            dgp.IdPacient = "c";
            dgp.Nume = "c";
            dgp.Prenume = "c";
            dgp.Sex = "c";
            dgp.DataNasterii = new DateTime(1987, 11, 01);
            dgp.LoculNasterii = "c";
            dgp.Resedinta = "c";
            dgp.DomiciliuLegal = "c";
            dgp.GrupaSanguina = "c";
            dgp.Ocupatie = "c";
            dgp.LocMunca = "c";
            dgp.TalonPensie = "c";

            PersistenceManager pm = PersistenceManager.Instance;
            pm.Save(dgp);

        }

      
    }
}
